<template>
    <div class="login-wrap">
        <div class="ms-title">简单约玩平台管理</div>
        <div class="ms-login">
            <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="0px" class="demo-ruleForm">
                <el-form-item prop="username">
                    <el-input v-model="ruleForm.username" placeholder="请输入账号名称" prefix-icon="el-ac-icon-wode"></el-input>
                </el-form-item>
                <el-form-item prop="password">
                    <el-input type="password" placeholder="请输入密码" prefix-icon="el-ac-icon-lock" v-model="ruleForm.password" @keyup.enter.native="submitForm('ruleForm')"></el-input>
                </el-form-item>
                <div class="login-btn">
                    <el-button type="primary" @click="submitForm('ruleForm')">登录</el-button>
                </div>
                 <div>
                    <el-col :span="6" class="login-msg">快速注册</el-col>
                    <el-col :span="6"  :offset="12" class="login-msg">忘记密码</el-col>
                </div>
            </el-form>
        </div>
    </div>
</template>

<script>
    export default {
        data: function(){
            return {
                ruleForm: {
                    username: '',
                    password: ''
                },
                rules: {
                    username: [
                        { required: true, message: '请输入用户名', trigger: 'blur' }
                    ],
                    password: [
                        { required: true, message: '请输入密码', trigger: 'blur' }
                    ]
                }
            }
        },
        methods: {
            submitForm(formName) {
                const self = this;
                self.$refs[formName].validate((valid) => {
                    if (valid) {
                        localStorage.setItem('ms_username',self.ruleForm.username);
                        self.$router.push('/userManage');
                    } else {
                        console.log('用户名密码有误');
                        return false;
                    }
                });
            }
        }
    }
</script>

<style>
    .login-wrap {
        position: relative;
        width:100%;
        height:100%;
        background: url(../assets/login-bg.jpg) no-repeat center center;
    }
    .ms-title{
        position: absolute;
        top:50%;
        width:100%;
        margin-top: -190px;
        text-align: center;
        font-size:30px;
        color: #000;

    }
    .ms-login{
        position: absolute;
        left:50%;
        top:50%;
        width:350px;
        height:160px;
        margin:-150px 0 0 -190px;
        padding:40px;
        border-radius: 5px;
        background: #fff;
    }
    .login-btn{
        text-align: center;
    }
    .login-btn button{
        width:100%;
        height:60px;
        border-radius: 25px;
    }

    .ms-login input{
        border-color: #dcdfe6 !important;
        border-radius: 25px;
        height: 60px;
        line-height: 60px;
    }

    .ms-login input:focus{
        border-color: #dcdfe6 !important;
    }
    .login-msg{
        font-size:13px;
        color:#dcdfe6;
        margin-top:10px;
    }

</style>
